import { Component, OnInit } from '@angular/core';
import { GlobalService } from '../../global/global.service';
import { PublishService } from './../../data/publish.service';

@Component({
  selector: 'app-publish',
  templateUrl: './publish.component.html',
  styleUrls: ['./publish.component.less']
})
export class PublishComponent implements OnInit {
  articleUrl = '';
  articleRead = '';
  articleTitle = '';
  articleTop = false;
  constructor(private globalService: GlobalService, private publishService: PublishService) { }

  ngOnInit() {
    this.globalService.setMessageText(true, '这是发布任务发出的信息');
  }

  submitPlan() {
    this.publishService.addTask({
      assistNum: Number(this.articleRead),
      rewardAmount: 0,
      taskLevel: this.articleTop ? 1 : 0,
      taskTime: new Date().getMilliseconds,
      title: this.articleTitle,
      url: this.articleUrl
    }).subscribe((response) => {
      console.log('执行成功');
    });
  }
}
